home *** CD-ROM | disk | FTP | other *** search
/ C/C++ Users Group Library 1996 July / C-C++ Users Group Library July 1996.iso / vol_300 / 353_02 / typeconv.cpp < prev    next >
C/C++ Source or Header  |  1992-01-18  |  645b  |  38 lines

  1.                                       // Chapter 2 - Program 5
  2. #include <iostream.h>
  3.  
  4. main()
  5. {
  6. int a = 2;
  7. float x = 17.1, y = 8.95, z;
  8. char c;
  9.  
  10.    c = (char)a + (char)x;
  11.    c = (char)(a + (int)x);
  12.    c = (char)(a + x);
  13.    c = a + x;
  14.  
  15.    z = (float)((int)x * (int)y);
  16.    z = (float)((int)x * (int)y);
  17.    z = (float)((int)(x * y));
  18.    z = x * y;
  19.  
  20.    c = char(a) + char(x);
  21.    c = char(a + int(x));
  22.    c = char(a + x);
  23.    c = a + x;
  24.  
  25.    z = float(int(x) * int(y));
  26.    z = float(int(x) * int(y));
  27.    z = float(int(x * y));
  28.    z = x * y;
  29. }
  30.  
  31.  
  32.  
  33.  
  34. // Result of execution
  35. //
  36. // (There is no output from this program)
  37.  
  38.